Add future=True flag to SA engine #17174
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ref #12541
The only fix that was required was a fix to a unit test setup. Here're the details:
Commit instead of flushing in unit test
Rationale:
We use an in-memory sqlite database for quota tests. With SA 2.0 (or with the
future
flag enabled on the engine), the following conflict happens: (this is a simplified model)Reason for BOOM:
With an in-memory database, the underlying dbapi_connection object is the same for the session and the engine.connect(). Here's what happens:
line 10: foo is flushed to the db tmp buffer
line 14: conn is closed on exit from context manager, which issues a rollback, which rolls back whatever is in the tmp buffer - so foo is never inserted.
line 16: foo is updated
line 17: error happens: the session thinks it's updating foo's record in the db, but that record does not exist therefore, "0 rows matched".
Solution: commit instead of flushing - then foo is inserted.
How to test the changes?
(Select all options that apply)
License